<?php
declare (strict_types=1);
namespace adminmatrix\server\app;

use think\App;
use think\Request;

use adminmatrix\server\app\middleware\{
    ReturnMiddleware,
    PermissionMiddleware
};
use adminmatrix\server\app\lists\BaseListsData;
abstract class AdminMatrix
{
    protected array $middleware = [
        ReturnMiddleware::class
        ,PermissionMiddleware::class
    ];
     protected Request $request;
     public function __construct(
         protected App $app
     )
    {
        $this->request = $this->app->request;
        // 控制器初始化
        $this->initialize();
    }

    // 初始化
    protected function initialize() : void
    {}



    public function dataLists( ?BaseListsData  $lists = null)
    {
        if (empty($lists) ||is_null($lists)) {
            $listName = str_replace('.' , '\\' , $this->app->getNamespace() . '\\lists\\' . $this->request->controller() . ucwords($this->request->action()));
            $lists    = invoke($listName);
        }

        return $lists;
    }
}